// custom-tab-bar/index.ts
Component({
	/**
	 * 组件的属性列表
	 */
	properties: {

	},

	/**
	 * 组件的初始数据
	 */
	data: {
		selected: 0,  //当前选中
		list: [
			{
				"pagePath": "/pages/index/index",
				"text": "首页",
				"iconPath": "../resources/home.png",
				"selectedIconPath": "../resources/home_active.png"
			},
			{
				"pagePath": "/pages/mall/index",
				"text": "商品",
				"iconPath": "../resources/mall.png",
				"selectedIconPath": "../resources/mall_active.png"
			},
			{
				"pagePath": "/pages/cart/cart",
				"text": "购物车",
				"iconPath": "../resources/cart.png",
				"selectedIconPath": "../resources/cart_active.png",
				"info": 3
			},
			{
				"pagePath": "/pages/message/index",
				"text": "消息",
				"iconPath": "../resources/message.png",
				"selectedIconPath": "../resources/message_active.png",
			}
			,
			{
				"pagePath": "/pages/mine/mine",
				"text": "我的",
				"iconPath": "../resources/mine.png",
				"selectedIconPath": "../resources/mine_active.png",
			}
		]
	},

	/**
	 * 组件的方法列表
	 */
	methods: {
		switchTab(e: any) {
			const { index, url } = e.currentTarget.dataset;
			if (this.data.selected == index || index == undefined) return;
			wx.switchTab({
				url
			})
			this.setData({
				selected: index
			})
		}
	}
})
